package router

import (
	"server/controller"

	"github.com/gin-gonic/gin"
)

// SetupHLSRoutes 设置HLS相关路由
func SetupHLSRoutes(r *gin.Engine) {
	hlsController := &controller.HLSController{}

	// HLS API路由组
	hlsGroup := r.Group("/api/hls")
	{
		// 上传视频并转换为HLS
		hlsGroup.POST("/convert", hlsController.ConvertToHLS)

		// 获取所有视频列表
		hlsGroup.GET("/videos", hlsController.ListVideos)

		// 删除指定视频
		hlsGroup.DELETE("/videos/:video_id", hlsController.DeleteVideo)

		// 获取HLS播放列表 (.m3u8文件)
		hlsGroup.GET("/:video_id/playlist.m3u8", hlsController.GetPlaylist)

		// 获取HLS视频片段 (.ts文件)
		hlsGroup.GET("/:video_id/:segment", hlsController.GetSegment)
	}

	// 静态文件服务（备用方案）
	r.Static("/static/hls", "./static/hls")
}
